package test.android;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.logging.Logger;
import java.util.regex.Pattern;

import android.accounts.Account;
import android.accounts.AccountManager;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.util.Patterns;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.VideoView;

public class MainActivity extends Activity {
	GestureDetector mGestureDetector;

	/** Called when the activity is first created. */
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main_layout);
		
//		ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext())
//		.threadPoolSize(3)
//		.threadPriority(Thread.NORM_PRIORITY - 2)
//		.memoryCacheSize(2 * 1024 * 1024) // 2.0 Mb
//		.memoryCache(new WeakMemoryCache())
//		.denyCacheImageMultipleSizesInMemory()
//		.discCacheFileNameGenerator(new Md5FileNameGenerator())
//		.tasksProcessingOrder(QueueProcessingType.FIFO)
//		.build();		
//		ImageLoader.getInstance().init(config);
//		
//		DisplayImageOptions options = new DisplayImageOptions.Builder()
//		.cacheInMemory()
//		.cacheOnDisc()
//		.build();

		
//		VideoView videoView = (VideoView) findViewById(R.id.videoview);
//		videoView.setVideoPath("rtsp://cdn.mivo.tv/mivotvjkt/sctv2_240p");
//		videoView.start();
		
		findViewById(R.id.btn).setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				launchApp("vn.sohagame.portal", "vn.sohagame.portal.MainActivity");
			}
		});
	}
	
	public void launchApp(String packageName, String activityClass) {
		Intent intent = new Intent(Intent.ACTION_MAIN);
		intent.setComponent(new ComponentName(packageName, activityClass));
		startActivity(intent);
	}
	
	private boolean isAppInstalled(String packageName) {
	    PackageManager pm = getPackageManager();
	    boolean installed = false;
	    try {
	       pm.getPackageInfo(packageName, PackageManager.GET_ACTIVITIES);
	       installed = true;
	    } catch (PackageManager.NameNotFoundException e) {
	    	e.printStackTrace();
	    	installed = false;
	    }
	    return installed;
	}	
	
	@TargetApi(Build.VERSION_CODES.GINGERBREAD)
	private void getAppInfo(String packageName) {
	    PackageManager pm = getPackageManager();
	    try {
	       PackageInfo packageInfo = pm.getPackageInfo(packageName, PackageManager.GET_ACTIVITIES);
	       Log.e("stk", "version name:" + packageInfo.versionName);
	       Log.e("stk", "version code:" + packageInfo.versionCode);
	       Log.e("stk", "firstInstall:" + packageInfo.firstInstallTime);
	       Log.e("stk", "last update:" + packageInfo.lastUpdateTime);
	       Log.e("stk", "name:" +packageInfo.applicationInfo.name);
	       
	    } catch (PackageManager.NameNotFoundException e) {
	    	e.printStackTrace();
	    }		
	}
	
}
